package com.springapp.model;

//import java.sql.Date;			//seems to be not required
import java.sql.Timestamp;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

import com.springapp.jsonmodel.OrderJson;

/*
 * 
 */
@Entity
@Table(name = "ORDERS")
public class Order extends BaseEntity {

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "DESK_ID")
    private Desk desk;

    @Column(name = "ORDER_OPEN_DATE")
    private Timestamp openDate;

    @Column(name = "ORDER_CLOSE_DATE")
    private Timestamp closeDate;
    
    @Enumerated(EnumType.STRING)
    @Column(name = "ORDER_STATUS")
    private OrderStatus status;

    @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, fetch = FetchType.EAGER,
            orphanRemoval = true)
    private List<ItemInOrder> itemsInOrder;

    public Order() {
    }
    

    public Desk getDesk() {
        return desk;
    }

    public void setDesk(Desk desk) {
        this.desk = desk;
    }

    public Timestamp getOpenDate() {
        return openDate;
    }

    public void setOpenDate(Timestamp openDate) {
        this.openDate = openDate;
    }

    public Timestamp getCloseDate() {
        return closeDate;
    }

    public void setCloseDate(Timestamp closeDate) {
        this.closeDate = closeDate;
    }

    public List<ItemInOrder> getItemsInOrder() {
        return itemsInOrder;
    }

    public void setItemsInOrder(List<ItemInOrder> itemsInOrder) {
        this.itemsInOrder = itemsInOrder;
    }

    public OrderStatus getStatus() {
        return status;
    }

    public void setStatus(OrderStatus status) {
        this.status = status;
    }

    
   
    
}
